<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/gsap@3.13.0/dist/gsap.min.js"></script>

    <script src="https://cdn.jsdelivr.net/npm/gsap@3.13.0/dist/ScrollTrigger.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/gsap@3.13.0/dist/TextPlugin.min.js"></script>
    <script src="./js/splitWordsFn.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }
        body {
            width: 100vw;
            height: 100vh;
            overflow: hidden;
        }
        .box1 {
            height: 100vh;
            /* background-color: #eee; */
            display: flex;
            align-items: center;
            justify-content: stretch;
        }
        .letters__group {
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .letters span {
            color: white;
            font-size: 1.6rem;
            min-width: 7px;
            display: inline-block;
            transform: translateY(-10vh) translateX(10vw) scale(3.5);
            opacity: 0;
        }
    </style>
</head>
<body>
    <div class="wrapper">
        <!-- <div class="box1"></div> -->
        <div class="letters__group">
            <div class="letters"></div>            
        </div>
        <div class="box1"></div>
        
        
      </div>

    <!-- <button id="animate">animate</button> -->
    <script>
        
        // use a script tag or an external JS file
        document.addEventListener("DOMContentLoaded", (event) => {
            gsap.registerPlugin(ScrollTrigger,TextPlugin)
            const words = 'Hello World!'
            const tl = gsap.timeline({ repeat: -1, yoyo: false })
            splitWordsFn(words, '.letters', (letterDom, i) => {
                tl.to(letterDom, {
                    y: 0,
                    x: 0,
                    scale: 1,
                    opacity: 1,
                    color: '#333',
                    duration: 0.5,
                    ease: "power1.inOut"
                }, i * 0.1);
            })

        });
       
       </script>
</body>
</html>